package com.yoomiito.app.net.http.repository

import com.yoomiito.app.net.http.ApiService
import com.yoomiito.app.net.http.RequestResponse
import com.yoomiito.app.net.http.RetrofitClient

open class BaseRepository {

    val service by lazy { RetrofitClient.instance.service(ApiService::class.java) }

    suspend fun <T>apiCall(call:suspend()-> RequestResponse<T>): RequestResponse<T> = call.invoke()

    suspend fun userInfo() = apiCall{service.userInfo()}

//    suspend fun <T>safeApiCall(call:suspend()->RequestResponse<T>):RequestResponse<T>{
//        try {
//            call()
//        }catch (e:Exception){
//            return RequestResponse(200,"",Nothing)
//        }
//    }
}